/*
 * MainWindow.java
 *
 * Created on 19 oktober 2009, 17:23
 */

package mop.gui.main;

import java.text.SimpleDateFormat;
import java.util.LinkedList;

import javax.swing.JButton;
import javax.swing.table.TableCellRenderer;

import mop.controller.ProjectController;
import mop.controller.ResourceController;
import mop.controller.TaskController;
import mop.controller.UserController;
import mop.gui.component.JTableButtonModel;
import mop.gui.component.JTableButtonMouseListener;
import mop.gui.component.JTableButtonRenderer;
import mop.gui.project.CreateProjectDialog;
import mop.gui.project.ProjectDetailsAction;
import mop.gui.project.RemoveProjectAction;
import mop.gui.resource.CreateResourceDialog;
import mop.gui.resource.MakeReservationAction;
import mop.gui.resource.RemoveResourceAction;
import mop.gui.task.AssignTaskAction;
import mop.gui.task.CreateTaskDialog;
import mop.gui.task.RemoveTaskAction;
import mop.gui.task.TaskDetailsAction;

/**
 *
 * @author  Laurens
 */
public class MainWindow extends javax.swing.JFrame {
    
    /**
     * Instance to self.
     */
    private static MainWindow instance = null;
    
    /**
     * Returns the instance of MainWindow.
     * 
     * @return  The static instance of MainWindow.
     */
    public static MainWindow getInstance()
    {
        return instance;	
    }
    
    /**
     * MainWindow constructor.
     * Initializes components.
     */
    public MainWindow()
    {
        initComponents();
        
        tableProjects.addMouseListener(new JTableButtonMouseListener(tableProjects));
        tableTasks.addMouseListener(new JTableButtonMouseListener(tableTasks));
        tableResources.addMouseListener(new JTableButtonMouseListener(tableResources));
        tableFocusWork.addMouseListener(new JTableButtonMouseListener(tableFocusWork));
        
        this.update();
        instance = this;
    }
    
    /**
     * Updates all tables in MainWindow.
     */
    public void update()
    {
        // Show current user.
        String currentUser = UserController.getInstance().getCurrentUser();
        this.lblCurrentUser.setText("Current User: " + currentUser);
        
        // Load projects table.
        this.loadProjects();
        
        // Load tasks table.
        this.loadUserTasks();
        
        // Load resources table.
        this.loadResources();
        
        // Focus work.
        this.loadFocusWork();
    }
    
    /***************************************************************************
     *                             projects
     ***************************************************************************/
    
    /**
     * Loads projects in projects table.
     */
    private void loadProjects()
    {
        LinkedList<String> projects = new LinkedList<String>();
        projects = (LinkedList<String>) ProjectController.getInstance().getProjectList();
        
        JTableButtonModel tableModel = new JTableButtonModel();
        
        String[] columns = {"Description", "Details", "Remove"};
        Object[][] rows = generateProjectRows(projects);
        
        tableModel.setColumns(columns);
        tableModel.setRows(rows);
        
        tableProjects.setModel(tableModel);
        TableCellRenderer defaultRenderer = tableProjects.getDefaultRenderer(JButton.class);
        JTableButtonRenderer buttonRenderer = new JTableButtonRenderer(defaultRenderer);
        tableProjects.setDefaultRenderer(JButton.class, buttonRenderer);
    }
    
    /**
     * Generates the rows of the project table.
     * 
     * @param   projects
     *          List of project descriptions.
     * @return  The rows for the table.
     */
    private Object[][] generateProjectRows(LinkedList<String> projects)
    {
        Object[][] rows = new Object[projects.size()][3];
        
        for ( int i = 0 ; i < projects.size() ; i++ ) {
            
            rows[i][0] = projects.get(i);
            
            rows[i][1] = new JButton("Details");
            ((JButton)rows[i][1]).addMouseListener(new ProjectDetailsAction(projects.get(i)));
            
            rows[i][2] = new JButton("Remove");
            ((JButton)rows[i][2]).addMouseListener(new RemoveProjectAction(projects.get(i)));
            
        }
        
        return rows;
    }
    
    /***************************************************************************
     *                             tasks
     ***************************************************************************/
    
    /**
     * Loads tasks for current user in tasks table.
     */
    private void loadUserTasks()
    {
        JTableButtonModel tableModel = new JTableButtonModel();
        
        String[] columns = {"Task", "Details", "Status", "Assign", "Remove"};
        
        Object[][] rows;
        
        try {
            LinkedList<String> tasks = new LinkedList<String>();
            tasks = (LinkedList<String>) TaskController.getInstance().getUserTasksList();
            rows = generateTaskRows(tasks);
        } catch (NullPointerException e) {
            rows = new Object[1][5];
            rows[0][0] = "";
            rows[0][1] = "";
            rows[0][2] = "";
            rows[0][3] = "";
            rows[0][4] = "";
        }
        
        tableModel.setColumns(columns);
        tableModel.setRows(rows);
        
        tableTasks.setModel(tableModel);
        TableCellRenderer defaultRenderer = tableTasks.getDefaultRenderer(JButton.class);
        JTableButtonRenderer buttonRenderer = new JTableButtonRenderer(defaultRenderer);
        tableTasks.setDefaultRenderer(JButton.class, buttonRenderer);
    }
    
    /**
     * Generates the rows of the tasks table.
     * 
     * @param   tasks
     *          List of task descriptions.
     * @return  The rows for the table.
     */
    private Object[][] generateTaskRows(LinkedList<String> tasks)
    {
        Object[][] rows = new Object[tasks.size()][5];
        
        for ( int i = 0 ; i < tasks.size() ; i++ ) {
            
            rows[i][0] = tasks.get(i);
            
            rows[i][1] = new JButton("Details");
            ((JButton)rows[i][1]).addMouseListener(new TaskDetailsAction(tasks.get(i)));
            
            rows[i][2] = new JButton("Status");
            ((JButton)rows[i][2]).addMouseListener(new TaskStatusAction(tasks.get(i)));
            
            rows[i][3] = new JButton("Assign");
            ((JButton)rows[i][3]).addMouseListener(new AssignTaskAction(tasks.get(i)));
            
            rows[i][4] = new JButton("Remove");
            ((JButton)rows[i][4]).addMouseListener(new RemoveTaskAction(tasks.get(i)));
            
        }
        
        return rows;
    }
    
    /***************************************************************************
     *                             resources
     ***************************************************************************/

    /**
     * Loads resources in resources table.
     */
    private void loadResources()
    {
        LinkedList<String> resources = new LinkedList<String>();
        resources = (LinkedList<String>) ResourceController.getInstance().getResourceList();
        
        JTableButtonModel tableModel = new JTableButtonModel();
        
        String[] columns = {"Description", "Make Reservation", "Remove"};
        Object[][] rows = generateResourceRows(resources);
        
        tableModel.setColumns(columns);
        tableModel.setRows(rows);
        
        tableResources.setModel(tableModel);
        TableCellRenderer defaultRenderer = tableResources.getDefaultRenderer(JButton.class);
        JTableButtonRenderer buttonRenderer = new JTableButtonRenderer(defaultRenderer);
        tableResources.setDefaultRenderer(JButton.class, buttonRenderer);
    }
    
    /**
     * Generates the rows of the resources table.
     * 
     * @param   resources
     *          List of resource descriptions.
     * @return  The rows for the table.
     */
    private Object[][] generateResourceRows(LinkedList<String> resources)
    {
        Object[][] rows = new Object[resources.size()][3];
        
        for ( int i = 0 ; i < resources.size() ; i++ ) {
            
            rows[i][0] = resources.get(i);
            
            rows[i][1] = new JButton("Make Reservation");
            ((JButton)rows[i][1]).addMouseListener(new MakeReservationAction(resources.get(i)));
            
            rows[i][2] = new JButton("Remove");
            ((JButton)rows[i][2]).addMouseListener(new RemoveResourceAction(resources.get(i)));
            
        }
        
        return rows;
    }
    
    
    /***************************************************************************
     *                             focus work
     ***************************************************************************/

    /**
     * Loads resources in resources table.
     */
    private void loadFocusWork()
    {
        JTableButtonModel tableModel = new JTableButtonModel();
        
        String[] columns = {"Task", "Deadline", "Details"};
        
        Object[][] rows;
        
        try {
            LinkedList<String> focusTasks = new LinkedList<String>();
            focusTasks = (LinkedList<String>) TaskController.getInstance().getFocusTasksList();
            rows = generateFocusWorkRows(focusTasks);
        } catch (NullPointerException e) {
            rows = new Object[1][3];
            rows[0][0] = "";
            rows[0][1] = "";
            rows[0][2] = "";
        }
        
        tableModel.setColumns(columns);
        tableModel.setRows(rows);
        
        tableFocusWork.setModel(tableModel);
        TableCellRenderer defaultRenderer = tableFocusWork.getDefaultRenderer(JButton.class);
        JTableButtonRenderer buttonRenderer = new JTableButtonRenderer(defaultRenderer);
        tableFocusWork.setDefaultRenderer(JButton.class, buttonRenderer);
    }
    
    /**
     * Generates the rows of the resources table.
     * 
     * @param   resources
     *          List of resource descriptions.
     * @return  The rows for the table.
     */
    private Object[][] generateFocusWorkRows(LinkedList<String> focusTasks)
    {
        Object[][] rows = new Object[focusTasks.size()][3];
        
        for ( int i = 0 ; i < focusTasks.size() ; i++ ) {
            
            rows[i][0] = focusTasks.get(i);
            
            SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm");
            rows[i][1] = formatter.format(TaskController.getInstance().getDetails(focusTasks.get(i)).get(1));
            
            rows[i][2] = new JButton("Details");
            ((JButton)rows[i][2]).addMouseListener(new TaskDetailsAction(focusTasks.get(i)));
            
        }
        
        return rows;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPane = new javax.swing.JTabbedPane();
        tabProjects = new javax.swing.JPanel();
        lblProjects = new javax.swing.JLabel();
        projectsPane = new javax.swing.JScrollPane();
        tableProjects = new javax.swing.JTable();
        btnCreateProject = new javax.swing.JButton();
        tabTasks = new javax.swing.JPanel();
        lblTasks = new javax.swing.JLabel();
        btnCreateTask = new javax.swing.JButton();
        tasksPane = new javax.swing.JScrollPane();
        tableTasks = new javax.swing.JTable();
        tabResources = new javax.swing.JPanel();
        lblResources = new javax.swing.JLabel();
        btnCreateResource = new javax.swing.JButton();
        paneResources = new javax.swing.JScrollPane();
        tableResources = new javax.swing.JTable();
        tabFocusWork = new javax.swing.JPanel();
        lblFocusWork = new javax.swing.JLabel();
        lblTasksDue = new javax.swing.JLabel();
        paneFocusWork = new javax.swing.JScrollPane();
        tableFocusWork = new javax.swing.JTable();
        lblCurrentUser = new javax.swing.JLabel();
        mainMenuBar = new javax.swing.JMenuBar();
        menuFile = new javax.swing.JMenu();
        itemQuit = new javax.swing.JMenuItem();
        menuHelp = new javax.swing.JMenu();
        itemForceUpdate = new javax.swing.JMenuItem();
        javax.swing.JMenu jMenu1 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("MOP Project"); // NOI18N
        setName("Form"); // NOI18N

        mainPane.setName("mainPane"); // NOI18N

        tabProjects.setName("tabProjects"); // NOI18N

        lblProjects.setFont(new java.awt.Font("Tahoma", 1, 18));
        lblProjects.setText("Projects"); // NOI18N
        lblProjects.setName("lblProjects"); // NOI18N

        projectsPane.setName("projectsPane"); // NOI18N

        tableProjects.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tableProjects.setName("tableProjects"); // NOI18N
        projectsPane.setViewportView(tableProjects);

        btnCreateProject.setText("Create Project"); // NOI18N
        btnCreateProject.setName("btnCreateProject"); // NOI18N
        btnCreateProject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateProjectActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout tabProjectsLayout = new javax.swing.GroupLayout(tabProjects);
        tabProjects.setLayout(tabProjectsLayout);
        tabProjectsLayout.setHorizontalGroup(
            tabProjectsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabProjectsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabProjectsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(projectsPane, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tabProjectsLayout.createSequentialGroup()
                        .addComponent(lblProjects)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 363, Short.MAX_VALUE)
                        .addComponent(btnCreateProject)))
                .addContainerGap())
        );
        tabProjectsLayout.setVerticalGroup(
            tabProjectsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabProjectsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabProjectsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCreateProject)
                    .addComponent(lblProjects))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(projectsPane, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
                .addContainerGap())
        );

        mainPane.addTab("Projects", tabProjects);
        loadProjects();

        tabTasks.setName("tabTasks"); // NOI18N

        lblTasks.setFont(new java.awt.Font("Tahoma", 1, 18));
        lblTasks.setText("Tasks"); // NOI18N
        lblTasks.setName("lblTasks"); // NOI18N

        btnCreateTask.setText("Create Task"); // NOI18N
        btnCreateTask.setName("btnCreateTask"); // NOI18N
        btnCreateTask.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateTaskActionPerformed(evt);
            }
        });

        tasksPane.setName("tasksPane"); // NOI18N

        tableTasks.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tableTasks.setName("tableTasks"); // NOI18N
        tasksPane.setViewportView(tableTasks);

        javax.swing.GroupLayout tabTasksLayout = new javax.swing.GroupLayout(tabTasks);
        tabTasks.setLayout(tabTasksLayout);
        tabTasksLayout.setHorizontalGroup(
            tabTasksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabTasksLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabTasksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tasksPane, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                    .addGroup(tabTasksLayout.createSequentialGroup()
                        .addComponent(lblTasks)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 395, Short.MAX_VALUE)
                        .addComponent(btnCreateTask)))
                .addContainerGap())
        );
        tabTasksLayout.setVerticalGroup(
            tabTasksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabTasksLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabTasksLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTasks)
                    .addComponent(btnCreateTask))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tasksPane, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
                .addContainerGap())
        );

        mainPane.addTab("Tasks", tabTasks);

        tabResources.setName("tabResources"); // NOI18N

        lblResources.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblResources.setText("Resources"); // NOI18N
        lblResources.setName("lblResources"); // NOI18N

        btnCreateResource.setText("Create Resource"); // NOI18N
        btnCreateResource.setName("btnCreateResource"); // NOI18N
        btnCreateResource.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateResourceActionPerformed(evt);
            }
        });

        paneResources.setName("paneResources"); // NOI18N

        tableResources.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tableResources.setName("tableResources"); // NOI18N
        paneResources.setViewportView(tableResources);

        javax.swing.GroupLayout tabResourcesLayout = new javax.swing.GroupLayout(tabResources);
        tabResources.setLayout(tabResourcesLayout);
        tabResourcesLayout.setHorizontalGroup(
            tabResourcesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabResourcesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabResourcesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(paneResources, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                    .addGroup(tabResourcesLayout.createSequentialGroup()
                        .addComponent(lblResources)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 335, Short.MAX_VALUE)
                        .addComponent(btnCreateResource)))
                .addContainerGap())
        );
        tabResourcesLayout.setVerticalGroup(
            tabResourcesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabResourcesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabResourcesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblResources)
                    .addComponent(btnCreateResource))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(paneResources, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)
                .addContainerGap())
        );

        mainPane.addTab("Resources", tabResources);

        tabFocusWork.setName("tabFocusWork"); // NOI18N

        lblFocusWork.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblFocusWork.setText("Focus Work");
        lblFocusWork.setName("lblFocusWork"); // NOI18N

        lblTasksDue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblTasksDue.setName("lblTasksDue"); // NOI18N

        paneFocusWork.setName("paneFocusWork"); // NOI18N

        tableFocusWork.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tableFocusWork.setName("tableFocusWork"); // NOI18N
        paneFocusWork.setViewportView(tableFocusWork);

        javax.swing.GroupLayout tabFocusWorkLayout = new javax.swing.GroupLayout(tabFocusWork);
        tabFocusWork.setLayout(tabFocusWorkLayout);
        tabFocusWorkLayout.setHorizontalGroup(
            tabFocusWorkLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabFocusWorkLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabFocusWorkLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(paneFocusWork, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                    .addGroup(tabFocusWorkLayout.createSequentialGroup()
                        .addComponent(lblFocusWork)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 434, Short.MAX_VALUE)
                        .addComponent(lblTasksDue)))
                .addContainerGap())
        );
        tabFocusWorkLayout.setVerticalGroup(
            tabFocusWorkLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabFocusWorkLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabFocusWorkLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFocusWork)
                    .addComponent(lblTasksDue))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(paneFocusWork, javax.swing.GroupLayout.DEFAULT_SIZE, 431, Short.MAX_VALUE)
                .addContainerGap())
        );

        mainPane.addTab("Focus Work", tabFocusWork);

        lblCurrentUser.setText("Current User:"); // NOI18N
        lblCurrentUser.setName("lblCurrentUser"); // NOI18N

        mainMenuBar.setName("mainMenuBar"); // NOI18N

        menuFile.setText("File"); // NOI18N
        menuFile.setName("menuFile"); // NOI18N

        itemQuit.setText("Quit"); // NOI18N
        itemQuit.setName("itemQuit"); // NOI18N
        itemQuit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemQuitActionPerformed(evt);
            }
        });
        menuFile.add(itemQuit);

        mainMenuBar.add(menuFile);

        menuHelp.setText("Help"); // NOI18N
        menuHelp.setName("menuHelp"); // NOI18N

        itemForceUpdate.setText("Force update tables");
        itemForceUpdate.setName("itemForceUpdate"); // NOI18N
        itemForceUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemForceUpdateActionPerformed(evt);
            }
        });
        menuHelp.add(itemForceUpdate);

        mainMenuBar.add(menuHelp);

        jMenu1.setName("jMenu1"); // NOI18N
        mainMenuBar.add(jMenu1);

        setJMenuBar(mainMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(mainPane, javax.swing.GroupLayout.DEFAULT_SIZE, 561, Short.MAX_VALUE)
                    .addComponent(lblCurrentUser))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mainPane, javax.swing.GroupLayout.DEFAULT_SIZE, 509, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblCurrentUser)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

/**
 * Opens the "create project" dialog.
 * 
 * @param   evt
 */
private void btnCreateProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateProjectActionPerformed
    CreateProjectDialog dialog = new CreateProjectDialog(new javax.swing.JFrame(), true);
    dialog.setVisible(true);
}//GEN-LAST:event_btnCreateProjectActionPerformed

/**
 * Forces an update of all tables.
 * 
 * @param   evt
 */
private void itemForceUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemForceUpdateActionPerformed
    this.update();
}//GEN-LAST:event_itemForceUpdateActionPerformed

/**
 * Closes the application.
 * @param   evt
 */
private void itemQuitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemQuitActionPerformed
    System.exit(0);
}//GEN-LAST:event_itemQuitActionPerformed

/**
 * Opens the "create project" dialog.
 * 
 * @param   evt
 */
private void btnCreateTaskActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateTaskActionPerformed
    CreateTaskDialog dialog = new CreateTaskDialog(new javax.swing.JFrame(), true);
    dialog.setVisible(true);
}//GEN-LAST:event_btnCreateTaskActionPerformed

private void btnCreateResourceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateResourceActionPerformed
    CreateResourceDialog dialog = new CreateResourceDialog(new javax.swing.JFrame(), true);
    dialog.setVisible(true);
}//GEN-LAST:event_btnCreateResourceActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCreateProject;
    private javax.swing.JButton btnCreateResource;
    private javax.swing.JButton btnCreateTask;
    private javax.swing.JMenuItem itemForceUpdate;
    private javax.swing.JMenuItem itemQuit;
    private javax.swing.JLabel lblCurrentUser;
    private javax.swing.JLabel lblFocusWork;
    private javax.swing.JLabel lblProjects;
    private javax.swing.JLabel lblResources;
    private javax.swing.JLabel lblTasks;
    private javax.swing.JLabel lblTasksDue;
    private javax.swing.JMenuBar mainMenuBar;
    private javax.swing.JTabbedPane mainPane;
    private javax.swing.JMenu menuFile;
    private javax.swing.JMenu menuHelp;
    private javax.swing.JScrollPane paneFocusWork;
    private javax.swing.JScrollPane paneResources;
    private javax.swing.JScrollPane projectsPane;
    private javax.swing.JPanel tabFocusWork;
    private javax.swing.JPanel tabProjects;
    private javax.swing.JPanel tabResources;
    private javax.swing.JPanel tabTasks;
    private javax.swing.JTable tableFocusWork;
    private javax.swing.JTable tableProjects;
    private javax.swing.JTable tableResources;
    private javax.swing.JTable tableTasks;
    private javax.swing.JScrollPane tasksPane;
    // End of variables declaration//GEN-END:variables

}
